<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="format-detection" content="telephone=no"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<title>微名片</title>
	<link rel="stylesheet" href="css/lt_common.css">
	<link rel="stylesheet" href="css/main_card.css">
</head>
<body>
	<div class="page">
		<input name="id" id="id" type="hidden"/>

		<input id="identity" type="hidden"/>
		<input id="credentials" type="hidden"/>
		<input id="development" type="hidden"/>

		<div class="bg_content">
			<div class="logo"></div>
			
		</div>
		<div class="per_infor">
			<!--
			<img src="img/default.png" alt="">
			<h3 class="name">王冲<i class="gender male">女</i></h3>
			<p><i class="tel_icon"></i>18911880166</p>
			-->
		</div>
		<div class="com_infor">
			<ul class="star_content">
				<!--
				<li class="star"></li>
				<li class="star"></li>
				<li class="star"></li>
				<li></li>
				<li></li>
				-->
			</ul>
			<p class="com_name">新华人寿北京分公司</p>
			<p class="markup">已为<em>426人</em>提供服务</p>
			<!-- <img id="erma" src="img/er.png" alt=""> -->
		</div>
		<div class="infor_list">
			<p id="validate"><i class="validate"></i>认证资料<span class="into"></span></p>
			<p id="more"><i class="more"></i>更多信息<span class="into"></span></p>
			<p id="simple"><i class="simple"></i>公司简介<span class="into"></span></p>
		</div>
		<ul class="foot_bar">
			<li id="busness"><i class="busness"></i>客户经营</li>
			<li><i class="share"></i>分享</li>
			<li id="write_info"><i class="write"></i>编辑</li>
		</ul>
	</div>
	<div class="share_mask">
		<img src="img/share_hint.png" height="574" width="511" alt="">
	</div>
	<!-- <div class="er_mask">
		<div class="content_div">
			<div class="er_content">
				<i class="off_window"></i>
				<img src="img/er2.png" alt="">
			</div>
			<div class="info_div">
				<img src="img/default.png" alt="">
				<h3>王冲</h3>
				<p>扫一扫二维码，关注我的公众号</p>
			</div>
		</div>
	</div> -->
</body>
</html>
<script src="js/jquery.js"></script>
<script src="js/common.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="js/weixin.js"></script>
<script>
	$(function(){
		
		//初始化
		initAction();

		$('.foot_bar li:nth-child(2)').on('click',function(){
			$('.share_mask').fadeIn('fast');
		});
		$('.share_mask').on('click',function(){
			$('.share_mask').fadeOut('fast');
		});
		$('#erma').on('click',function(){
			$('.er_mask').fadeIn('fast');
		});
		$('.off_window').on('click',function(){
			$('.er_mask').fadeOut('fast');
		});
		//认证信息
		$('#validate').on('click',function(){
			//身份证号
			var identity = $('#identity').val();
			//资格证号
			var credentials = $('#credentials').val();
			//展业证号
			var development = $('#development').val();
			window.location = 'validate_infor.html?openid='+ origopenid + '&identity='+identity+'&credentials='+credentials+'&development='+development+'&agent_status='+getQueryString('agent_status');
		});
		//更多信息
		$('#more').on('click',function(){
			window.location = 'more_infor.html?openid='+ origopenid;
		});
		$('#simple').on('click',function(){
			window.location = 'company_infor.html?openid='+ origopenid;
		});
		$('#write_info').on('click',function(){
			window.location = 'write_information.html?origopenid='+ origopenid;
		});
		$('#busness').on('click',function(){
			window.location = 'customer_busness.html?openid='+ origopenid;
		});
		$('.bg_content').on('click',function(){
			window.location = 'weiActive/share_active.html?origopenid='+ origopenid + '&lastopenid='+lastopenid;
		});
		
	});
</script>
<script>
	//判断状态,为0只显示分享,为1说明是代理人本人显示更多选项
	var agent_status = getQueryString('agent_status');
	
	var code = getQueryString('code');
	var share_name = '';
	var share_img = '';
	//初始化界面
	function initAction(){
		if(code==null || code==''){
			lastopenid = origopenid;
		}else{
			$.ajax({
				url: API_URL+'agent/getopenid?code='+code,
				type: 'get',
				dataType: "JSON",
				data:'',
				async: false,
				success: function (obj){
					if(obj.status.code == 0) {
						lastopenid = obj.data[0].openid;
					}
				},
				error: function (data){
					console.log("服务器异常!");
				}
			});
			if(lastopenid==origopenid){
				agent_status = 1;
			}
		}
		
		//alert("origopenid--->"+origopenid+'----->lastopenid'+lastopenid);
		
		if(agent_status != 1){
			$('.foot_bar li:first-child').hide();
			$('.foot_bar li:last-child').hide();
			$('.foot_bar li').width('100%');
		}
		$.ajax({
			url: API_URL+'agentcard/getagent?openid='+origopenid,
			type: 'GET',
			dataType: "JSON",
			data:'',
			async: false,
			success: function (obj){
				if (obj.status.code == 0) {
					var myData = obj.data;
					for(var i=0; i < myData.length; i++){
						var agentItem = myData[i];
						if(agentItem.icon == null || agentItem.icon == ''){
							agentItem.icon ='img/default.png';
						}
						share_name = agentItem.name;
						share_img = agentItem.icon;
						//名称与头像赋值
						var Str_icon = '<img src=\"'+agentItem.icon+'\" alt="">';
						Str_icon += '<h3 class="name">'+agentItem.name;
						if(agentItem.gender == "女"){
							Str_icon += '<i class="gender ">女</i>';	
						}else{
							Str_icon += '<i class="gender male">男</i>';
						}
						Str_icon += '</h3>';
						Str_icon += '<p><a href="tel:'+agentItem.phone+'"><i class="tel_icon"></i>'+agentItem.phone+'</a></p>';
						$('.per_infor').html(Str_icon);
						
						//星级赋值
						var Str_star = '';
						for(var j = 1 ; j <= 5 ; j ++){
							if(agentItem.star >= j){
								Str_star += '<li class="star"></li>';
							}else{
								Str_star += '<li ></li>';
							}
						}
						$('.star_content').html(Str_star);
						//单位名称
						$('.com_name').html(agentItem.branch);
						//已服务人数
						var agent_count = agentItem.agent_service_count;
						if(agent_count==0){
							agent_count = '*';
						}
						$('.markup').html('已为<em>'+agent_count+'人</em>提供服务');
						
						//二维码提示信息
						var Str_qrcode = '<img src=\"'+agentItem.icon+'\" alt=""><h3>'+agentItem.name+'</h3><p>扫一扫二维码，关注我的公众号</p>';
						$('.info_div').html(Str_qrcode);

						//二维码图片
						if(agentItem.qrcode == null ||  agentItem.qrcode == ''){
							agentItem.qrcode = 'img/er2.png';
						}
						var Str = '<i class="off_window"></i><img src=\"'+agentItem.qrcode+'\" alt="">';
						// $('.er_content').html(Str);
						//身份证号
						$('#identity').val(agentItem.identity);
						//资格证号
						$('#credentials').val(agentItem.credentials);
						//展业证号
						$('#development').val(agentItem.development);
					}
				}
			},
			error: function (data){
				console.log("服务器异常!");
			}
		});

		var share_obj = {
			title : '快来看看，名片里有惊喜！',
			desc : '我是'+share_name+'，给您拜年啦！',
			link : 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx497082f7a8e4b806&redirect_uri='+
			'http%3A%2F%2Fwww.ladyflora.com%2FweiChartCard%2Fmain_card.html%3Fagent_status%3D0%26origopenid%3D'+origopenid
			+'&response_type=code&scope=snsapi_base&state=#wechat_redirect',
			imgUrl : share_img
		}
		wx_share_element.init(share_obj);
	}

	//分享成功,记录
	function shareSuccess(){
		var share_success_url = API_URL+'forward/pleaseforward?origopenid='+origopenid+'&lastopenid='+lastopenid+'&type=1';
		$.ajax({
			url: share_success_url,
			type: 'get',
			dataType: "JSON",
			data:'',
			async: false
		});
	}
</script>